<?php
class CultivateFlowerVo extends SzAbstractMySqlVo
{

    private $userId;
    private $flowerId;
    private $last_info;
    private $current_info;
    private $cultivated;

    /**
     * Initialize CultivateFlowerVo.
     *
     * @param $userId
     * @param $flowerId
     * @param $last_info
     * @param $current_info
     * @param $cultivated
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return CultivateFlowerVo
     */
    public function __construct($userId, $flowerId, $last_info, $current_info, $cultivated, $isInsert = false) {
        $this->userId = $userId;
        $this->flowerId = $flowerId;
        $this->last_info = json_decode($last_info, true);
        $this->current_info = json_decode($current_info, true);
        $this->cultivated = $cultivated;

        $this->isInsert = $isInsert;
        $this->voClassName = 'CultivateFlowerVo';
        $this->ormName = 'CultivateFlower';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'flowerId' => $this->getFlowerId(),
            'last_info' => ($needEncode) ? $this->getLast_info() : $this->getRawLast_info(),
            'current_info' => ($needEncode) ? $this->getCurrent_info() : $this->getRawCurrent_info(),
            'cultivated' => $this->getCultivated(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'flowerId' => $this->getFlowerId(),
            'last_info' => ($needEncode) ? $this->getLast_info() : $this->getRawLast_info(),
            'current_info' => ($needEncode) ? $this->getCurrent_info() : $this->getRawCurrent_info(),
            'cultivated' => $this->getCultivated(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getFlowerId(),
            $this->getLast_info(),
            $this->getCurrent_info(),
            $this->getCultivated(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getFlowerId()
    {
        return $this->flowerId;
    }

    public function setFlowerId($val)
    {
        $this->saveColumnStatus(1, $this->flowerId);
        $this->flowerId = $val;
    }

    public function getLast_info()
    {
        return json_encode($this->last_info);
    }

    public function getRawLast_info()
    {
        return $this->last_info;
    }

    public function setLast_info($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 512) {
            SzLogger::get()->error('[CultivateFlowerVo] The length of column last_info exceed the limit, length / limit: ' . $encodedLength . ' / 512');
            throw new SzException(10522, array('CultivateFlowerVo', '512', $encodedLength));
        } else if ($encodedLength > 460) {
            SzLogger::get()->warn('[CultivateFlowerVo] The length of column last_info exceed the warning level, length / limit: ' . $encodedLength . ' / 512');
        }
        $this->saveColumnStatus(2, $this->last_info);
        $this->last_info = $val;
    }

    public function getCurrent_info()
    {
        return json_encode($this->current_info);
    }

    public function getRawCurrent_info()
    {
        return $this->current_info;
    }

    public function setCurrent_info($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 512) {
            SzLogger::get()->error('[CultivateFlowerVo] The length of column current_info exceed the limit, length / limit: ' . $encodedLength . ' / 512');
            throw new SzException(10522, array('CultivateFlowerVo', '512', $encodedLength));
        } else if ($encodedLength > 460) {
            SzLogger::get()->warn('[CultivateFlowerVo] The length of column current_info exceed the warning level, length / limit: ' . $encodedLength . ' / 512');
        }
        $this->saveColumnStatus(3, $this->current_info);
        $this->current_info = $val;
    }

    public function getCultivated()
    {
        return $this->cultivated;
    }

    public function setCultivated($val)
    {
        $this->saveColumnStatus(4, $this->cultivated);
        $this->cultivated = $val;
    }

}